package com.happy.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

@Configuration
public class MvcWebConfig implements WebMvcConfigurer {


    @Override
    public void addViewControllers (ViewControllerRegistry registry) {

    }

    @Resource
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors (InterceptorRegistry registry) {
        registry.addInterceptor ( loginInterceptor ).addPathPatterns ( "/admin/**" )
                .addPathPatterns ( "/answer/**" ).addPathPatterns ( "/category/**" ).addPathPatterns ( "/collection/**" ).addPathPatterns ( "/course/**" ).addPathPatterns ( "/exam/**" )
                .addPathPatterns ( "/follow/**" ).addPathPatterns ( "/note/**" ).addPathPatterns ( "/paper/**" ).addPathPatterns ( "/question/**" ).addPathPatterns ( "/record/**" )
                .addPathPatterns ( "/report/**" ).addPathPatterns ( "/subject/**" ).addPathPatterns ( "/user/**" ).excludePathPatterns ( "/admin/querySingle" );
    }
}
